package com.xmy.cultivate.listeners;

import com.xmy.cultivate.constants.MqConstants;
import com.xmy.cultivate.entity.Staff;
import com.xmy.cultivate.respons.QyWeChartPushRs;
import com.xmy.cultivate.service.IQyWacherService;
import com.xmy.cultivate.service.IStaffService;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class QyWechartListener {

    @Autowired
    IStaffService iStaffService;

    @Autowired
    IQyWacherService iqyWacherService;

    /**
     * 企业微信帐号同步
     * @param staff
     */
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(name = MqConstants.QUEUE_QY_WECHART_ACCOUNT_Q1, durable = "true"),
//            exchange = @Exchange(name = MqConstants.EXCHANGE_QY_WECHART_ACCOUNT_FANOUT, type = ExchangeTypes.FANOUT)
//    ))
//    public void updateQyWecharId(Staff staff) throws WxErrorException {
//        iStaffService.updateQyWecharId(staff);
//    }
//
//
//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(name = MqConstants.QUEUE_QY_WECHART_PUSH_MSG_Q1, durable = "true"),
//            exchange = @Exchange(name = MqConstants.EXCHANGE_QY_WECHART_PUSH_MSG_FANOUT, type = ExchangeTypes.FANOUT)
//    ))
//    public void pushContent(QyWeChartPushRs qyWeChartPushRs) throws WxErrorException {
//        if (qyWeChartPushRs.getMsgType().equals("textcard")){
//            iqyWacherService.pushCardContent(qyWeChartPushRs);
//        }else {
//            iqyWacherService.pushTxtContent(qyWeChartPushRs);
//        }
//
//    }


}
